package store;

import store.Service.BuyCar;
import store.Service.SelfInfomation;
import store.control.UserService;
import store.Service.Store;

import java.util.Scanner;

public class Index {
    static Scanner sc = new Scanner(System.in);
    public static void Index() {
        while (true) {
            printHeader();
            System.out.println("                1.用户登录");
            System.out.println("                2.用户注册");
            System.out.println("                3.退出系统");
            printHeader();
            System.out.println("请选择菜单：");

            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    UserService.login();
                    break;
                case 2:
                    UserService.register();
                    break;
                case 3:
                    System.out.println("系统退出成功，谢谢使用");
                    System.exit(0);
                default:
                    System.out.println("输入错误，请重新输入");
                    return;
            }
        }

    }
    public static void Indexstore() {
        while (true) {
            printHeader();
            System.out.println("                1.商品购买");
            System.out.println("                2.我的购物车");
            System.out.println("                3.个人信息");
            System.out.println("                4.注销");
            printHeader();
            System.out.println("请选择菜单：");

            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    Store.buyGoods();
                    break;
                case 2:
                    BuyCar.buyCar();
                    break;
                case 3:
                    SelfInfomation.Infomation();
                    break;
                case 4:
                    SelfInfomation.CancelLogin();
                    break;
            }
        }
    }

    private static void printHeader() {
        System.out.println("******************电器商城******************");
    }

}
